<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libCZI: libCZI/libCZI_Utilities.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" async src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libCZI
   </div>
   <div id="projectbrief">Reading CZI documents made easy</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('lib_c_z_i___utilities_8h_source.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">libCZI_Utilities.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">//******************************************************************************</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">// </span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">// libCZI is a reader for the CZI fileformat written in C++</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">// Copyright (C) 2017  Zeiss Microscopy GmbH</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">// </span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment">// This program is free software: you can redistribute it and/or modify</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment">// it under the terms of the GNU General Public License as published by</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment">// the Free Software Foundation, either version 3 of the License, or</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment">// (at your option) any later version.</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment">// </span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment">// This program is distributed in the hope that it will be useful,</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment">// GNU General Public License for more details.</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment">// </span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment">// You should have received a copy of the GNU General Public License</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment">// along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment">// </span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment">// To obtain a commercial version please contact Zeiss Microscopy GmbH.</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment">// </span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment">//******************************************************************************</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacelib_c_z_i.html">libCZI</a></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;{</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    <span class="keyword">class </span>ISubBlockRepository;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="classlib_c_z_i_1_1_utils.html">   30</a></span>&#160;    <span class="keyword">class </span>LIBCZI_API <a class="code" href="classlib_c_z_i_1_1_utils.html">Utils</a></div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    {</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <span class="keyword">public</span>:</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        <span class="keyword">static</span> <span class="keywordtype">char</span> DimensionToChar(<a class="code" href="namespacelib_c_z_i.html#a55049658acf59d0eddfaebcad16df424">libCZI::DimensionIndex</a> dim);</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;        <span class="keyword">static</span> <a class="code" href="namespacelib_c_z_i.html#a55049658acf59d0eddfaebcad16df424">libCZI::DimensionIndex</a> CharToDimension(<span class="keywordtype">char</span> c);</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        <span class="keyword">static</span> <span class="keywordtype">int</span> CalcMd5SumHash(<a class="code" href="classlib_c_z_i_1_1_i_bitmap_data.html">libCZI::IBitmapData</a>* bm, std::uint8_t* ptrHash, <span class="keywordtype">int</span> hashSize);</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;        <span class="keyword">static</span> <span class="keywordtype">int</span> CalcMd5SumHash(<span class="keyword">const</span> <span class="keywordtype">void</span>* ptrData, <span class="keywordtype">size_t</span> sizeData, std::uint8_t* ptrHash, <span class="keywordtype">int</span> hashSize);</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;        <span class="keyword">static</span> std::vector&lt;std::uint8_t&gt; Create8BitLookUpTableFromSplines(<span class="keywordtype">int</span> tableElementCnt, <span class="keywordtype">float</span> blackPoint, <span class="keywordtype">float</span> whitePoint, <span class="keyword">const</span> std::vector&lt;libCZI::IDisplaySettings::SplineData&gt;&amp; splineData);</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;        <span class="keyword">static</span> std::vector&lt;std::uint8_t&gt; Create8BitLookUpTableFromGamma(<span class="keywordtype">int</span> tableElementCnt, <span class="keywordtype">float</span> blackPoint, <span class="keywordtype">float</span> whitePoint, <span class="keywordtype">float</span> gamma);</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;        <span class="keyword">static</span> std::vector&lt;libCZI::IDisplaySettings::SplineData&gt; CalcSplineDataFromPoints(<span class="keywordtype">int</span> pointCnt, std::function&lt; std::tuple&lt;double, double&gt;(<span class="keywordtype">int</span> idx)&gt; getPoint);</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;        <span class="keyword">static</span> std::shared_ptr&lt;libCZI::IBitmapData &gt; NearestNeighborResize(<a class="code" href="classlib_c_z_i_1_1_i_bitmap_data.html">libCZI::IBitmapData</a>* bmSrc, <span class="keywordtype">int</span> dstWidth, <span class="keywordtype">int</span> dstHeight);</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;        <span class="keyword">static</span> std::shared_ptr&lt;libCZI::IBitmapData &gt; NearestNeighborResize(<a class="code" href="classlib_c_z_i_1_1_i_bitmap_data.html">libCZI::IBitmapData</a>* bmSrc, <span class="keywordtype">int</span> dstWidth, <span class="keywordtype">int</span> dstHeight, <span class="keyword">const</span> <a class="code" href="structlib_c_z_i_1_1_dbl_rect.html">DblRect</a>&amp; roiSrc, <span class="keyword">const</span> <a class="code" href="structlib_c_z_i_1_1_dbl_rect.html">DblRect</a>&amp; roiDest);</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;</div><div class="line"><a name="l00114"></a><span class="lineno"><a class="line" href="classlib_c_z_i_1_1_utils.html#a68bf3739b6be924bcdf01664492f0a0a">  114</a></span>&#160;        <span class="keyword">static</span> <span class="keywordtype">float</span> <a class="code" href="classlib_c_z_i_1_1_utils.html#a68bf3739b6be924bcdf01664492f0a0a">CalcZoom</a>(<span class="keyword">const</span> <a class="code" href="structlib_c_z_i_1_1_int_rect.html">libCZI::IntRect</a>&amp; logicalRect, <span class="keyword">const</span> <a class="code" href="structlib_c_z_i_1_1_int_size.html">libCZI::IntSize</a>&amp; physicalSize)</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;        {</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;            <span class="keywordflow">if</span> (physicalSize.<a class="code" href="structlib_c_z_i_1_1_int_size.html#a62979309ccf04e31423b494e68c80957">w</a> &gt; physicalSize.<a class="code" href="structlib_c_z_i_1_1_int_size.html#a04b144b6c7cd7b6e994bad25a46dfdf5">h</a>)</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;            {</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;                <span class="keywordflow">return</span> float(physicalSize.<a class="code" href="structlib_c_z_i_1_1_int_size.html#a62979309ccf04e31423b494e68c80957">w</a>) / logicalRect.<a class="code" href="structlib_c_z_i_1_1_int_rect.html#ad83af8b748b2fdbf5ac96ff1773e623b">w</a>;</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;            }</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;            <span class="keywordflow">else</span></div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;            {</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;                <span class="keywordflow">return</span> float(physicalSize.<a class="code" href="structlib_c_z_i_1_1_int_size.html#a04b144b6c7cd7b6e994bad25a46dfdf5">h</a>) / logicalRect.<a class="code" href="structlib_c_z_i_1_1_int_rect.html#a59e7b7e0a9190fae3973e2da2bf7d173">h</a>;</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;            }</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;        }</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;        <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* PixelTypeToInformalString(<a class="code" href="namespacelib_c_z_i.html#abf8ce12ab88b06c8b3b47efbb5e2e834">libCZI::PixelType</a> pxltp);</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;        <span class="keyword">static</span> std::string DimCoordinateToString(<span class="keyword">const</span> <a class="code" href="classlib_c_z_i_1_1_i_dim_coordinate.html">libCZI::IDimCoordinate</a>* coord);</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;        <span class="keyword">static</span> std::shared_ptr&lt;libCZI::IIndexSet&gt; IndexSetFromString(<span class="keyword">const</span> std::wstring&amp; s);</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;        <span class="keyword">static</span> <a class="code" href="namespacelib_c_z_i.html#abf8ce12ab88b06c8b3b47efbb5e2e834">libCZI::PixelType</a> TryDeterminePixelTypeForChannel(<a class="code" href="classlib_c_z_i_1_1_i_sub_block_repository.html">libCZI::ISubBlockRepository</a>* repository, <span class="keywordtype">int</span> channelIdx);</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    };</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;}</div><div class="ttc" id="namespacelib_c_z_i_html_abf8ce12ab88b06c8b3b47efbb5e2e834"><div class="ttname"><a href="namespacelib_c_z_i.html#abf8ce12ab88b06c8b3b47efbb5e2e834">libCZI::PixelType</a></div><div class="ttdeci">PixelType</div><div class="ttdoc">An enum representing a pixel-type. </div><div class="ttdef"><b>Definition:</b> libCZI_Pixels.h:126</div></div>
<div class="ttc" id="structlib_c_z_i_1_1_dbl_rect_html"><div class="ttname"><a href="structlib_c_z_i_1_1_dbl_rect.html">libCZI::DblRect</a></div><div class="ttdoc">A rectangle (with double coordinates). </div><div class="ttdef"><b>Definition:</b> libCZI_Pixels.h:91</div></div>
<div class="ttc" id="classlib_c_z_i_1_1_i_bitmap_data_html"><div class="ttname"><a href="classlib_c_z_i_1_1_i_bitmap_data.html">libCZI::IBitmapData</a></div><div class="ttdef"><b>Definition:</b> libCZI_Pixels.h:166</div></div>
<div class="ttc" id="structlib_c_z_i_1_1_int_rect_html_ad83af8b748b2fdbf5ac96ff1773e623b"><div class="ttname"><a href="structlib_c_z_i_1_1_int_rect.html#ad83af8b748b2fdbf5ac96ff1773e623b">libCZI::IntRect::w</a></div><div class="ttdeci">int w</div><div class="ttdoc">The width of the rectangle. </div><div class="ttdef"><b>Definition:</b> libCZI_Pixels.h:36</div></div>
<div class="ttc" id="structlib_c_z_i_1_1_int_size_html_a04b144b6c7cd7b6e994bad25a46dfdf5"><div class="ttname"><a href="structlib_c_z_i_1_1_int_size.html#a04b144b6c7cd7b6e994bad25a46dfdf5">libCZI::IntSize::h</a></div><div class="ttdeci">std::uint32_t h</div><div class="ttdoc">The height. </div><div class="ttdef"><b>Definition:</b> libCZI_Pixels.h:106</div></div>
<div class="ttc" id="structlib_c_z_i_1_1_int_rect_html_a59e7b7e0a9190fae3973e2da2bf7d173"><div class="ttname"><a href="structlib_c_z_i_1_1_int_rect.html#a59e7b7e0a9190fae3973e2da2bf7d173">libCZI::IntRect::h</a></div><div class="ttdeci">int h</div><div class="ttdoc">The height of the rectangle. </div><div class="ttdef"><b>Definition:</b> libCZI_Pixels.h:37</div></div>
<div class="ttc" id="classlib_c_z_i_1_1_utils_html"><div class="ttname"><a href="classlib_c_z_i_1_1_utils.html">libCZI::Utils</a></div><div class="ttdoc">A bunch of utility functions. </div><div class="ttdef"><b>Definition:</b> libCZI_Utilities.h:30</div></div>
<div class="ttc" id="classlib_c_z_i_1_1_i_dim_coordinate_html"><div class="ttname"><a href="classlib_c_z_i_1_1_i_dim_coordinate.html">libCZI::IDimCoordinate</a></div><div class="ttdoc">Interface used to represent a coordinate (in the space of the dimensions identified by DimensionIndex...</div><div class="ttdef"><b>Definition:</b> libCZI_DimCoordinate.h:54</div></div>
<div class="ttc" id="structlib_c_z_i_1_1_int_rect_html"><div class="ttname"><a href="structlib_c_z_i_1_1_int_rect.html">libCZI::IntRect</a></div><div class="ttdoc">A rectangle (with integer coordinates). </div><div class="ttdef"><b>Definition:</b> libCZI_Pixels.h:32</div></div>
<div class="ttc" id="namespacelib_c_z_i_html"><div class="ttname"><a href="namespacelib_c_z_i.html">libCZI</a></div><div class="ttdoc">External interfaces, classes, functions and structs are found in the namespace &quot;libCZI&quot;. </div><div class="ttdef"><b>Definition:</b> libCZI.h:44</div></div>
<div class="ttc" id="namespacelib_c_z_i_html_a55049658acf59d0eddfaebcad16df424"><div class="ttname"><a href="namespacelib_c_z_i.html#a55049658acf59d0eddfaebcad16df424">libCZI::DimensionIndex</a></div><div class="ttdeci">DimensionIndex</div><div class="ttdoc">Values that represent dimension indexes. </div><div class="ttdef"><b>Definition:</b> libCZI_DimCoordinate.h:34</div></div>
<div class="ttc" id="structlib_c_z_i_1_1_int_size_html"><div class="ttname"><a href="structlib_c_z_i_1_1_int_size.html">libCZI::IntSize</a></div><div class="ttdoc">A structure representing a size (width and height) in integers. </div><div class="ttdef"><b>Definition:</b> libCZI_Pixels.h:103</div></div>
<div class="ttc" id="classlib_c_z_i_1_1_utils_html_a68bf3739b6be924bcdf01664492f0a0a"><div class="ttname"><a href="classlib_c_z_i_1_1_utils.html#a68bf3739b6be924bcdf01664492f0a0a">libCZI::Utils::CalcZoom</a></div><div class="ttdeci">static float CalcZoom(const libCZI::IntRect &amp;logicalRect, const libCZI::IntSize &amp;physicalSize)</div><div class="ttdef"><b>Definition:</b> libCZI_Utilities.h:114</div></div>
<div class="ttc" id="classlib_c_z_i_1_1_i_sub_block_repository_html"><div class="ttname"><a href="classlib_c_z_i_1_1_i_sub_block_repository.html">libCZI::ISubBlockRepository</a></div><div class="ttdoc">Interface for sub-block repository. This interface is used to access the sub-blocks in a CZI-file...</div><div class="ttdef"><b>Definition:</b> libCZI.h:391</div></div>
<div class="ttc" id="structlib_c_z_i_1_1_int_size_html_a62979309ccf04e31423b494e68c80957"><div class="ttname"><a href="structlib_c_z_i_1_1_int_size.html#a62979309ccf04e31423b494e68c80957">libCZI::IntSize::w</a></div><div class="ttdeci">std::uint32_t w</div><div class="ttdoc">The width. </div><div class="ttdef"><b>Definition:</b> libCZI_Pixels.h:105</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_21e977e93a9d37f41c2225f78f35f145.html">libCZI</a></li><li class="navelem"><b>libCZI_Utilities.h</b></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
